package bean;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Flight generated by hbm2java
 */
@Entity
@Table(name = "flight", catalog = "bdd_dev_n_tiers")
public class Flight implements java.io.Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private String name;
	private String departureTown;
	private Date departureTime;
	private String arrivalTown;
	private Date arrivalTime;
	private Set<Hotel> hotels = new HashSet<Hotel>(0);
	private Set<Panel> panels = new HashSet<Panel>(0);
	
	public Flight() {
	}

	public Flight(String name, String departureTown, Date departureTime,
			String arrivalTown, Date arrivalTime) {
		this.name = name;
		this.departureTown = departureTown;
		this.departureTime = departureTime;
		this.arrivalTown = arrivalTown;
		this.arrivalTime = arrivalTime;
	}

	public Flight(String name, String departureTown, Date departureTime,
			String arrivalTown, Date arrivalTime, Set<Hotel> hotels, Set<Panel> panels) {
		this.name = name;
		this.departureTown = departureTown;
		this.departureTime = departureTime;
		this.arrivalTown = arrivalTown;
		this.arrivalTime = arrivalTime;
		this.hotels = hotels;
		this.panels = panels;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", nullable = false, length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "departure_town", nullable = false, length = 50)
	public String getDepartureTown() {
		return this.departureTown;
	}

	public void setDepartureTown(String departureTown) {
		this.departureTown = departureTown;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "departure_time", nullable = false, length = 0)
	public Date getDepartureTime() {
		return this.departureTime;
	}

	public void setDepartureTime(Date departureTime) {
		this.departureTime = departureTime;
	}

	@Column(name = "arrival_town", nullable = false, length = 50)
	public String getArrivalTown() {
		return this.arrivalTown;
	}

	public void setArrivalTown(String arrivalTown) {
		this.arrivalTown = arrivalTown;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "arrival_time", nullable = false, length = 0)
	public Date getArrivalTime() {
		return this.arrivalTime;
	}

	public void setArrivalTime(Date arrivalTime) {
		this.arrivalTime = arrivalTime;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "assoc_flight_hotel", catalog = "bdd_dev_n_tiers", joinColumns = { @JoinColumn(name = "id_flight", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "id_hotel", nullable = false, updatable = false) })
	public Set<Hotel> getHotels() {
		return this.hotels;
	}

	public void setHotels(Set<Hotel> hotels) {
		this.hotels = hotels;
	}
	
	@JsonIgnore
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "flight")
	public Set<Panel> getPanels() {
		return this.panels;
	}

	public void setPanels(Set<Panel> panels) {
		this.panels = panels;
	}

}
